package com;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */



import java.util.List;
import javax.jws.WebMethod;
import javax.jws.WebService;
import koncowka.Ap;
import koncowka.Klient;
import org.applets.regula.Regula;

/**
 *
 * @author Michał
 */
@WebService(name = "serwer")
//@SOAPBinding(style = SOAPBinding.Style.RPC)
public class Polaczenie {
    
    private List<Ap> listaAp;
    private List<Regula> listaRegul;
    
    @WebMethod
    public List<Ap> pobierzSieci ()
    {
        return listaAp;  
    }
    
    @WebMethod
    public List<Regula> pobierzReguly()
    {
        return listaRegul;
    }
    
    @WebMethod
    public void wyslijSieci(List<Ap> listaSieci)
    {
        if(listaAp==null || listaAp.isEmpty())
            listaAp=listaSieci;
        else
        {
            for (Ap ap : listaSieci) {
                if(listaAp.contains(ap))
                {
                    Ap ap1 = listaAp.get(listaAp.indexOf(ap));
                    for (Klient klient : ap.getListaKlientow()) {
                        if(!ap1.getListaKlientow().contains(klient))
                        {
                            ap1.getListaKlientow().add(klient);
                        }
                    }
                }else
                {
                    listaAp.add(ap);
                }
            }
        }
    }
    
    @WebMethod
    public void wyslijReguly(List<Regula> listaRegul)
    {
        this.listaRegul=listaRegul;
    }
    
        
}
